package qmm.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import qmm.dao.UserDao;
import qmm.dao.impl.UserDaoImpl;
import qmm.entity.User;
import qmm.util.JdbcUtil;

@WebServlet("/EditCardServlet")
public class EditCardServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public EditCardServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		String card = request.getParameter("card");
		UserDao dao = new UserDaoImpl();
		int n = dao.editCard(card, user.getId());
		if(n>0){
			user.setIdCardNo(card);
			session.setAttribute("user", user);//ˢsession
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
